package com.qiangqiang.dao.concrete;

import com.qiangqiang.adapter.SqlAdaptee;
import com.qiangqiang.adapter.SqlAdapter;
import com.qiangqiang.adapter.SqlHandler;
import com.qiangqiang.entity.Clazs;

/**
 * Created by q on 2018/4/6.
 */
public class ClassDao {

    public void insert(Clazs clazs) {
        StringBuffer sb = new StringBuffer("insert into class values(");
        sb.append(clazs.getClassId() + ",").append("'" + clazs.getMajor() + "'" + ",").append(clazs.getClassNumber() + ",")
                .append(clazs.getYear() + ")");
        new SqlAdapter().execute(sb.toString());
    }

    public void delete(int classId) {
        StringBuffer sb = new StringBuffer("delete from class where class_id=").append(classId);
        new SqlAdapter().execute(sb.toString());
    }

    public Clazs queryById(int classId) {
        StringBuffer sb = new StringBuffer("select * from class where class_id= ").append(classId);
        return (Clazs) new SqlAdapter().executeQuery(sb.toString(), Clazs.class);
    }
}
